﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Security;
using ViewRes;

namespace DiplomaWeb.Models.Account
{
    public class AccountMembershipService : IMembershipService
    {
        private readonly MembershipProvider provider;

        public AccountMembershipService()
            : this(null)
        {
        }

        public AccountMembershipService(MembershipProvider provider)
        {
            this.provider = provider ?? Membership.Provider;
        }

        public bool ValidateUser(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName))
                throw new ArgumentException(AccountStrings.AccountMembershipService_ValidateUser_Value_cannot_be_null_or_empty_, "userName");
            if (String.IsNullOrEmpty(password))
                throw new ArgumentException(AccountStrings.AccountMembershipService_ValidateUser_Value_cannot_be_null_or_empty_, "password");

            return provider.ValidateUser(userName, password);
        }
    }
}